const { DataTypes } = require('sequelize');
const sequelize = require('../../config/database');

// 定义 prize 模型
const Prize = sequelize.define('prizes', {
  id: {
    type: DataTypes.INTEGER,
    autoIncrement: true,
    primaryKey: true
  },
  prize_image: {
    type: DataTypes.STRING(255),
    allowNull: false,
    comment: '奖品图片URL或路径'
  },
  prize_name: {
    type: DataTypes.STRING(100),
    allowNull: false,
    comment: '奖品名称'
  },
  prize_description: {
    type: DataTypes.TEXT,
    allowNull: true,
    comment: '奖品介绍'
  },
  points: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: '兑换所需积分'
  },
  stock: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: '库存数量'
  },
  created_at: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    comment: '创建时间'
  },
  updated_at: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    comment: '更新时间'
  }
}, {
  tableName: 'prizes',
  timestamps: false
});

module.exports = Prize;
